package io.renren.modules.generator.controller;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.generator.entity.MBlogEntity;
import io.renren.modules.generator.service.MBlogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-11-18 14:38:09
 */
@RestController
@RequestMapping("generator/mblog")
public class MBlogController {
    @Autowired
    private MBlogService mBlogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("generator:mblog:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = mBlogService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    // @RequiresPermissions("generator:mblog:info")
    public R info(@PathVariable("id") Long id) {
        MBlogEntity mBlog = mBlogService.getById(id);

        return R.ok().put("mBlog", mBlog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:mblog:save")
    public R save(@RequestBody MBlogEntity mBlog) {
        mBlogService.save(mBlog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:mblog:update")
    public R update(@RequestBody MBlogEntity mBlog) {
        mBlogService.updateById(mBlog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:mblog:delete")
    public R delete(@RequestBody Long[] ids) {
        mBlogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
